package com.produce.user.mapper;

import com.produce.user.dto.RoleTreeDto;
import com.produce.user.entity.RoleTree;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

/**
 * 类描述：菜单数据转换工具
 *
 * @author linzf
 */
@Mapper(componentModel = "spring")
public interface RoleTreeMapper {

    /**
     * 功能描述：实现数据的转换
     *
     * @param entity
     * @return
     */
    @Mapping(target = "title", source = "name")
    @Mapping(source = "treeId", target = "treeId")
    RoleTreeDto treeToTreeDTO(RoleTree entity);

    /**
     * 功能描述：实现菜单实体的数据转换
     * @param entity
     * @return
     */
    @Mapping(target = "name", source = "title")
    @Mapping(source = "treeId", target = "treeId")
    RoleTree treeDtoToTree(RoleTreeDto entity);


    /**
     * 功能描述：实现集合的数据的转换，这边先设置实体之间的转换集合的设置才会实现
     *
     * @param trees
     * @return
     */
    List<RoleTreeDto> treesToTreeDTO(List<RoleTree> trees);

    /**
     * 功能描述：实现集合的数据的转换，这边先设置实体之间的转换集合的设置才会实现
     *
     * @param trees
     * @return
     */
    List<RoleTree> treeDTOToTrees(List<RoleTreeDto> trees);


}
